const app = getApp();
const publicFun = require('/utils/public.js')
import { getClimateActionTJ } from '/utils/request'
Page({
  data: {
    rewardList: [
      {id: 1, title: '气候达人勋章', cover: '/images/my/reward_medal.png', 
      text: '气候达人勋章是为激励用户在参与气候行动公益活动时，通过不断打卡气候行动而获取的专属勋章，并且随着气候行动打卡次数的增加可以不断提升勋章等级。', total: 15, get: 11, state: '未获得', 
      url: '/pages/myMedal/myMedal'},
      {id: 2, title: '气候达人证书', cover: '/images/my/reward_certificate.png', 
      text: '气候行动公益证书是蔚蓝地图给积极参与气候行动打卡活动的用户所发放的专属公益证书，鼓励用户在日常践行绿色低碳生活，为减排做出自己的贡献，助力美丽中国建设！', total: 15, get: 11, state: '未获得',
      url: '/pages/myCertificateList/myCertificateList'}
    ]
  },
  onLoad() {
    my.setNavigationBarColor({
      frontColor: '#000000',
      backgroundColor: '#ffffff',
    });
    this.setData({
      userData: app.globalData.userData,
    });
    this.getTJList();
  },
  seeDetailTap(e) {
    let url = e.currentTarget.dataset.url;
    my.navigateTo({
      url: url
    })
  },
  async getTJList() { 
    try{
      var params = {
        userid: app.globalData.userid,
      }
      const res = await getClimateActionTJ(params)
      if(res.S == 1){
        let data = res;
        this.setData({ myClimateData: data })
      }else{
        publicFun.showToast(res.M ? res.M : '加载失败')
      }
    }catch(e){
      publicFun.showToast('失败，请稍后再试')
    }
  },
});
